package com.lc202309;

/**
 * Description:
 *
 * @Create 2023/9/8 22:18
 * @Version 1.0
 */
public class Solution2409 {
    public static int countDaysTogether(String arriveAlice, String leaveAlice, String arriveBob, String leaveBob) {
        if (leaveAlice.compareTo(arriveBob) < 0 || leaveBob.compareTo(arriveAlice) < 0) {
            return 0;
        }
        String min = arriveAlice.compareTo(arriveBob) > 0 ? arriveAlice : arriveBob;
        String max = leaveAlice.compareTo(leaveBob) > 0 ? leaveBob : leaveAlice;
        int[] months = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        String[] mins = min.split("-");
        String[] maxs = max.split("-");
        int startMonth = Integer.parseInt(mins[0]);
        int startDay = Integer.parseInt(mins[1]);
        int endMonth = Integer.parseInt(maxs[0]);
        int endDay = Integer.parseInt(maxs[1]);
        int res = endDay - startDay + 1;
        for (int i = startMonth; i < endMonth; i++) {
            res = res + months[i - 1];
        }
        return res;
    }

    public static void main(String[] args) {
        System.out.println(Integer.parseInt("08"));
        System.out.println(Integer.parseInt("04"));
        System.out.println(Integer.parseInt("00"));
        System.out.println("-------------");
        System.out.println(countDaysTogether("03-05", "07-14", "04-14", "09-21"));
    }
}
